<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>新增</title>
    <script src="../layui/layui.js"></script>
    <link rel="stylesheet" href="../layui/css/layui.css">
    <script src="../js/jquery.js"></script>
    <script src="../js/myAjax.js"></script>
    <script src="../js/util/add.js"></script>
</head>
<body>
<div style="margin-left: 50px; margin-top: 120px">
    <div class="layui-form-item">
        <label class="layui-form-label">组名：</label>
        <div class="layui-input-inline">
            <input type="text" name="title" required lay-verify="required" id="group-name" autocomplete="off"
                   class="layui-input">
        </div>
        <div class="layui-form-mid layui-word-aux"></div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">成立时间：</label>
        <div class="layui-inline"> <!-- 注意：这一层元素并不是必须的 -->
            <input type="text"  class="layui-input" id="establishedTime">
        </div>
        <div class="layui-form-mid layui-word-aux"></div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" onclick="newAdd('/group/add',getData())">立即提交</button>
            <button type="reset" onclick="resetAdd('/html/groupAdd.html')" class="layui-btn layui-btn-primary">
                点击重置
            </button>
        </div>
    </div>
</div>
<script>
    function getData() {
        let data = {
            name: $("#group-name").val(),
            // leader: $("#leader").val(),
            establishedTime: $("#establishedTime").val(),
        }
        return data;
    }
    //获取当前时间并以默认值赋值给定义好的text编辑框，如果不符合具体时间可自行修改或重新获取当前时间
    layui.use('laydate', function(){
        var laydate = layui.laydate;

        //执行一个laydate实例
        laydate.render({
            elem: '#establishedTime' //指定元素
            ,type: 'datetime'
            ,format: 'yyyy-MM-dd HH:mm'
            ,value: new Date()
        });
    });
</script>
</body>
</html>